This notebook covers Analysis 2 of the pre-registration (https://osf.io/mq64z/), investigating the difference between no-signal and stop-respond RT at the individual level.
All paths in the code are relative to the project directory.
project_dir <- rprojroot::find_root(rprojroot::has_file("DESCRIPTION"))derivatives_dir <- file.path(project_dir,"data","derivatives")
figures_dir <- file.path(project_dir, "figures")
notebook_name <- params$title
irmass::verify_output_dirs(base_dirs = list(derivatives_dir, figures_dir),
notebook_name = notebook_name)(expt_trial_rt_data <-
readr::read_csv(file.path(derivatives_dir,
"02_assess_task_performance_criteria",
"tidy_expt_trial_rt_data_for_analysis.csv"),
col_types = irmass::get_col_types("expt_trial_rt_data")
)
)(cleaned_trial_level_data <-
expt_trial_rt_data %>%
# Keep relevant trials only -------------------------------------------------
# Responses that are:
# ... non-anticipatory
dplyr::filter(RT_trial > 0.150) %>%
# ... bimanual
dplyr::filter(r == "RB") %>%
# ... no-stop or stop-signal
dplyr::filter(trial_alt %in% c('SAS', 'SSS', 'NS')) %>%
# Compute inverse of RT ------------------------------------------------------
# This is the dependent variable in the analysis
dplyr::mutate(RT_trial_inv = 1 / RT_trial) %>%
# Keep relevant columns only -------------------------------------------------
dplyr::select(subjectIx, trial_alt, RT_trial, RT_trial_inv) %>%
# Ensure that subjectIx is coded as a factor (for plotting) ------------------
dplyr::mutate(subjectIx = factor(subjectIx))
)Action-selective stopping
(analysis_inputs_sas <-
cleaned_trial_level_data %>%
dplyr::filter(trial_alt %in% c('SAS','NS')) %>%
droplevels()
)Stimulus-selective stopping
(analysis_inputs_sss <-
cleaned_trial_level_data %>%
dplyr::filter(trial_alt %in% c('SSS','NS')) %>%
droplevels()
)Prediction of \(H_0\): action-selective stop-respond response times are not shorter than no-stop response times Prediction of \(H_1\): action-selective stop-respond response times are shorter than no-stop response times
(analysis_outputs_sas <-
irmass::test_srrt_vs_nsrt_idv(tibb = analysis_inputs_sas,
trial_alt_levels = c('SAS','NS')
)
)Prediction of \(H_0\): stimulus-selective stop-respond RT \(\not<\) no-signal RT Prediction of \(H_1\): stimulus-selective stop-respond RT < no-signal RT
(analysis_outputs_sss <-
irmass::test_srrt_vs_nsrt_idv(tibb = analysis_inputs_sss,
trial_alt_levels = c('SSS','NS')
)
)(plt_sas <- irmass::plot_srrt_vs_nsrt_idv(trial_data = analysis_inputs_sas,
bf_data = analysis_outputs_sas,
plot_orientation = 'horizontal')
)## Warning: Removed 2 rows containing missing values (position_quasirandom).
## Warning: Removed 1 rows containing missing values (position_quasirandom).
## Warning: Removed 1 rows containing missing values (position_quasirandom).
Figure title
plt_sas_title <- 'Response times on action-selective stop-respond trials and no-signal trials.'Figure description
plt_description <- 'Each panel shows data from one participant, including (i) response time distirbutions on individual stop-respond trials and no-signal trials, displayed as violin scatter plots (each asterisk is a trial); (ii) mean response time across trials, indicated by white, filled circles; (iii) the Bayes factor quantifying the evidence for $H_0$ vs $H_1$ ($B_{01}$), indicated by the panel background color; (iv) the subject identifier, indicated by the number in the top-right corner. Panels are ordered by $B_{01}$ (descending order).'(plt_sss <- irmass::plot_srrt_vs_nsrt_idv(trial_data = analysis_inputs_sss,
bf_data = analysis_outputs_sss,
plot_orientation = 'horizontal'
)
)## Warning: Removed 2 rows containing missing values (position_quasirandom).
## Warning: Removed 1 rows containing missing values (position_quasirandom).
## Warning: Removed 1 rows containing missing values (position_quasirandom).
Figure title
plt_sss_title <- 'Response times on stimulus-selective stop-respond trials and no-signal trials.'readr::write_csv(analysis_inputs_sas,
path = file.path(derivatives_dir,
notebook_name,
paste('analysis_inputs',
notebook_name,
'action_selective_stopping',
'rt_data.csv',
sep = '_')
),
col_names = TRUE)readr::write_csv(analysis_inputs_sss,
path = file.path(derivatives_dir,
notebook_name,
paste('analysis_inputs',
notebook_name,
'stimulus_selective_stopping',
'rt_data.csv',
sep = '_')
),
col_names = TRUE)Bayes factors
readr::write_csv(analysis_outputs_sas,
path = file.path(derivatives_dir,
notebook_name,
paste('analysis_outputs',
notebook_name,
'action_selective_stopping',
'b01.csv',
sep = '_')
),
col_names = TRUE)readr::write_csv(analysis_outputs_sss,
path = file.path(derivatives_dir,
notebook_name,
paste('analysis_outputs',
notebook_name,
'stimulus_selective_stopping',
'b01.csv',
sep = '_')
),
col_names = TRUE)Consists of analysis input data and analysis output data, which are already written to disk.
Figures
# Figure
filename_plt_sas <-
paste('plot',
notebook_name,
'action_selective_stopping.pdf',
sep = '_')
ggplot2::ggsave(plot = plt_sas,
path = file.path(figures_dir, notebook_name),
filename = filename_plt_sas,
device = "pdf",
width = 18,
height = 13.5,
units = 'cm'
)## Warning: Removed 2 rows containing missing values (position_quasirandom).
## Warning: Removed 1 rows containing missing values (position_quasirandom).
## Warning: Removed 1 rows containing missing values (position_quasirandom).
# Figure caption
irmass::write_fig_cap(
fig_title = plt_sas_title,
fig_description = plt_description,
fig_dir = figures_dir,
notebook_name = notebook_name,
stopping_type = "action_selective")## [1] "/Users/bramzandbelt/surfdrive/projects/irmass/figures/04_individual_analysis_rt_difference_nosignal_stoprespond/plot_caption_04_individual_analysis_rt_difference_nosignal_stoprespond_action_selective_stopping.txt"
# Figure
filename_plt_sss <-
paste('plot',
notebook_name,
'stimulus_selective_stopping.pdf',
sep = '_')
cowplot::ggsave(plot = plt_sss,
path = file.path(figures_dir, notebook_name),
filename = filename_plt_sss,
width = 18,
height = 13.5,
units = 'cm'
)## Warning: Removed 2 rows containing missing values (position_quasirandom).
## Warning: Removed 1 rows containing missing values (position_quasirandom).
## Warning: Removed 1 rows containing missing values (position_quasirandom).
# Figure caption
irmass::write_fig_cap(
fig_title = plt_sss_title,
fig_description = plt_description,
fig_dir = figures_dir,
notebook_name = notebook_name,
stopping_type = "stimulus_selective")## [1] "/Users/bramzandbelt/surfdrive/projects/irmass/figures/04_individual_analysis_rt_difference_nosignal_stoprespond/plot_caption_04_individual_analysis_rt_difference_nosignal_stoprespond_stimulus_selective_stopping.txt"